function formatNumber (n) {
    const str = n.toString()
    return str[1] ? str : `0${str}`
}

export function formatTime (date) {
    const year = date.getFullYear()
    const month = date.getMonth() + 1
    const day = date.getDate()

    const hour = date.getHours()
    const minute = date.getMinutes()
    const second = date.getSeconds()

    const t1 = [year, month, day].map(formatNumber).join('/')
    const t2 = [hour, minute, second].map(formatNumber).join(':')

    return `${t1} ${t2}`
}

export function debounce (func, delay) {
    let timer
    return function (...args) {
        if (timer) {
            window.clearTimeout(timer)
        }
        timer = window.setTimeout(() => {
            func.apply(this, args)
        }, delay)
    }
}

// 商保状态(-1全部，0退保，1在保)
export const hasInsuranceStatus = [
    {
        name: '全部',
        value: -1
    },
    {
        name: '退保',
        value: 0
    },
    {
        name: '在保',
        value: 1
    }
]
